<?php

// 物联网，数据推送给不同厂家的不同硬件设备
// 创建实体接口方法-人脸设备工厂
interface RenlianFactory {
	public function getName();
}
class RenlianBasic implements RenlianFactory {
	public function getName()
	{
		return ('这是人脸设备，基础版规格');
	}
}
class RenlianUpgraded implements RenlianFactory {
	public function getName()
	{
		return ('这是人脸设备，升级版规格');
	}
}
class RenlianTop implements RenlianFactory {
	public function getName()
	{
		return ('这是人脸设备，顶级版规格');
	}
}
class RenlianNull implements RenlianFactory {
	public function getName() {
		return ('未知的人脸设备，提供你的详细参数或向客服反馈；');
	}
}

// 创建实体接口方法-指纹设备工厂
interface ZhiwenFactory {
	public function getName();
}
class Zhiwen200 implements ZhiwenFactory {
	public function getName() {
		return ('这是指纹设备，型号 style_200 ；');
	}
}
class Zhiwen300 implements ZhiwenFactory {
	public function getName() {
		return ('这是指纹设备，型号 style_300 ；');
	}
}
class Zhiwen400 implements ZhiwenFactory {
	public function getName() {
		return ('这是指纹设备，型号 style_400 ；');
	}
}
class ZhiwenNull implements ZhiwenFactory {
	public function getName() {
		return ('未知的指纹设备，提供你的详细参数或向客服反馈；');
	}
}

// 一个总厂，总厂旗下可提供设备的工厂（指纹设备工厂、人脸设备工厂）
abstract class AbstractSalesFactory {
	abstract protected function getDevice(string $style);
}
class SalesRelianFactory extends AbstractSalesFactory {
	public function getDevice(string $style)
	{
		switch($style) {
			case 'basic':
				return new RenlianBasic();
				break;
			case 'upgraded':
				return new RenlianUpgraded();
				break;
			case 'top':
				return new RenlianTop();
				break;
			default:
				return new RenlianNull();
				break;
		}
		return null;
	}
}
class SalesZhiwenFactory extends AbstractSalesFactory {
	public function getDevice(string $style) {
		switch($style) {
			case '200':
				return new Zhiwen200();
				break;
			case '300':
				return new Zhiwen300();
				break;
			case '400':
				return new Zhiwen400();
				break;
			default:
				return new ZhiwenNull();
				break;
		}
	}
}

// 创建设备产品类
class DeviceProduct {
	public static function __callStatic($name, $arguments)
	{
		switch($name) {
			case 'zhiwen':
				return new SalesZhiwenFactory($arguments);
				break;
			case 'renlian':
				return new SalesRelianFactory($arguments);
				break;
		}

		exit('不存在的产品线！');
	}
}

// 使用
echo '<pre>';
var_dump([
	'指纹设备问询' => [
		DeviceProduct::zhiwen()->getDevice('200')->getName(),
		DeviceProduct::zhiwen()->getDevice('300')->getName(),
		DeviceProduct::zhiwen()->getDevice('900')->getName(),
	],
	'人脸设备问询' => [
		DeviceProduct::renlian()->getDevice('basic')->getName(),
		DeviceProduct::renlian()->getDevice('top')->getName(),
		DeviceProduct::renlian()->getDevice('vvvip')->getName(),
	],
]);
